package com.example.travel.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.travel.R;


public class MyListViewAdapter extends BaseAdapter {
    private Context context;
    private int [] imageView;
    private String [] name;
    private String [] price;
    private String [] introduce;

    public MyListViewAdapter(Context context, int[] imageView, String[] name, String[] price, String[] introduce) {
        this.context = context;
        this.imageView = imageView;
        this.name = name;
        this.price = price;
        this.introduce = introduce;
    }

    @Override
    public int getCount() {
        return name.length;
    }

    @Override
    public Object getItem(int i) {
        return name[i];
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LinearLayout linearLayout = (LinearLayout)view.inflate(context, R.layout.browselistpro,null);
        ImageView imageView1 = linearLayout.findViewById(R.id.iv1);
        imageView1.setImageResource(imageView[i]);
        TextView textView1_1 = linearLayout.findViewById(R.id.tx1_1);
        textView1_1.setText(name[i]);
        TextView textView1_2 = linearLayout.findViewById(R.id.tx1_2);
        textView1_2.setText(price[i]);
        TextView textView1_3 = linearLayout.findViewById(R.id.tx1_3);
        textView1_3.setText(introduce[i]);
        return linearLayout;
    }

}
